package com.tougutips.controller;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.tougutips.common.goods.vo.SeckGoodsVO;
import com.tougutips.entity.SeckillGoods;
import com.tougutips.service.SeckillGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/seckillgoods")
public class SeckillGoodsController {
    @Autowired
    private SeckillGoodsService seckillGoodsService;
    @GetMapping("/list")
    public AjaxResult list(){
        List<SeckillGoods> list = seckillGoodsService.list();
        return AjaxResult.success(list);
    }

    /**
     * 新增秒杀活动商品
     * @param goods
     * @return
     */
    @PostMapping
    public AjaxResult save(@RequestBody SeckillGoods goods){

        boolean save = seckillGoodsService.save(goods);
        if(save) return AjaxResult.success("新增秒杀成功");
        return AjaxResult.error("新增秒杀失败");
    }

    /**
     * 减库存接口
     * @param seckGoodsVO
     * @return
     */
    @PostMapping("/seckill")
    public AjaxResult seckill(@RequestBody SeckGoodsVO seckGoodsVO){
        return AjaxResult.success();
    }
}
